package com.lsec.springbootinit.event.user;

import com.lsec.springbootinit.config.AsyncPoolConfig;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.time.Clock;

/**
 * 用户注册监听器
 *
 * @author Cherry
 * @date 2023-06-21 14:02
 */


@Component
public class UserRegisterListener  {

    @EventListener
    @Async(AsyncPoolConfig.TASK_EXECUTOR_NAME)
    public void onApplicationEvent(UserRegisterEvent userRegisterEvent) throws InterruptedException {
        while (true){
            Thread.sleep(1000);
            System.out.println("线程id = " + Thread.currentThread().getName() + "  " +  Thread.currentThread().getId());
        }
//        String name = userRegisterEvent.getName();
//        System.out.println("监听者执行 --- name = " + name + "线程id = " + Thread.currentThread().getName() + Thread.currentThread().getId());
    }

}
